/*
 * Filename BldAnalysisServiceImpl.java 2022年05月18日
 * Copyright © Ehome Co.Ltd. All Rgiths Reserved.
 * @author wuyingchao
 */
package com.ehome.poct.core.service.report;

import com.ehome.core.service.AbstractCrudServiceImpl;
import com.ehome.poct.core.api.dto.report.BldAnalysisDTO;
import com.ehome.poct.core.api.virtual.BldAnalysisService;
import com.ehome.poct.core.repository.report.BldAnalysisRepository;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * @author wyc
 * @since 2022/05/18 14:03
 **/
@Service
@AllArgsConstructor
public class BldAnalysisServiceImpl extends AbstractCrudServiceImpl<BldAnalysisDTO> implements BldAnalysisService {
    private final BldAnalysisRepository bldAnalysisRepository;

    @Override
    public BldAnalysisDTO getWbcByCode(String code) {
        return Optional.ofNullable(bldAnalysisRepository.selectByCode(code, 1))
                .orElseGet(() -> bldAnalysisRepository.selectByCode("000000000000", 1));
    }

    @Override
    public BldAnalysisDTO getRbcByCode(String code) {
        return bldAnalysisRepository.selectByCode(code, 2);
    }
}